home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 14 / CU Amiga Magazine's Super CD-ROM 14 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-09].iso / CUCD / Programming / IEditor / Expanders / Gauge.desc < prev    next >
Encoding:
Text File  |  1997-06-17  |  2.7 KB  |  118 lines

  1. ##SUPPORT
  2.  
  3. void DrawFuel( struct Window *Wnd, struct FuelGauge *Gauge )
  4. {
  5.     DrawBevelBox( Wnd->RPort,
  6.                   Gauge->Left + XOffset,
  7.                   Gauge->Top  + YOffset,
  8.                   Gauge->Width,
  9.                   Gauge->Height,
  10.                   GT_VisualInfo, VisualInfo,
  11.                   GTBB_Recessed, TRUE,
  12.                   TAG_DONE );
  13. }
  14.  
  15. void SetFuel( struct Window *Wnd, struct FuelGauge *Gauge )
  16. {
  17.     UWORD x, y, x2, y2;
  18.  
  19.     x = Gauge->Left + XOffset;
  20.     y = Gauge->Top  + YOffset;
  21.  
  22.     if ( Gauge->Tot != 0 ) {
  23.  
  24.         if( Gauge->Freedom ) {
  25.             x2 = x + Gauge->Width - 3;
  26.             y2 = y + (( Gauge->Height - 1 ) * Gauge->Part ) / Gauge->Tot;
  27.         } else {
  28.             x2 = x + (( Gauge->Width - 2 ) * Gauge->Part ) / Gauge->Tot;
  29.             y2 = y + Gauge->Height - 2;
  30.         }
  31.  
  32.         SetAPen( Wnd->RPort, 3 );
  33.         RectFill( Wnd->RPort, x + 2, y + 1, x2, y2 );
  34.  
  35.     } else {
  36.  
  37.         SetAPen( Wnd->RPort, 0 );
  38.         RectFill( Wnd->RPort,
  39.                   x + 2, y + 1,
  40.                   x + Gauge->Width - 3,
  41.                   y + Gauge->Height - 2 );
  42.     }
  43. }
  44.  
  45. ##SUPPORT-FA
  46.  
  47. void DrawFuel( struct Window *Wnd, struct FuelGauge *Gauge )
  48. {
  49.     DrawBevelBox( Wnd->RPort,
  50.                   ScaleX( Gauge->Left ) + XOffset,
  51.                   ScaleY( Gauge->Top  ) + YOffset,
  52.                   ScaleX( Gauge->Width ),
  53.                   ScaleY( Gauge->Height ),
  54.                   GT_VisualInfo, VisualInfo,
  55.                   GTBB_Recessed, TRUE,
  56.                   TAG_DONE );
  57. }
  58.  
  59. void SetFuel( struct Window *Wnd, struct FuelGauge *Gauge )
  60. {
  61.     UWORD x, y, x2, y2;
  62.  
  63.     x = ScaleX( Gauge->Left ) + XOffset;
  64.     y = ScaleY( Gauge->Top  ) + YOffset;
  65.  
  66.     if ( Gauge->Tot != 0 ) {
  67.  
  68.         if( Gauge->Freedom ) {
  69.             x2 = x + ScaleX( Gauge->Width ) - 3;
  70.             y2 = y + ((( ScaleY( Gauge->Height ) - 1 ) * Gauge->Part ) / Gauge->Tot );
  71.         } else {
  72.             x2 = x + ((( ScaleX( Gauge->Width ) - 2 ) * Gauge->Part ) / Gauge->Tot );
  73.             y2 = y + ScaleY( Gauge->Height ) - 2;
  74.         }
  75.  
  76.         SetAPen( Wnd->RPort, 3 );
  77.         RectFill( Wnd->RPort, x + 2, y + 1, x2, y2 );
  78.  
  79.     } else {
  80.  
  81.         SetAPen( Wnd->RPort, 0 );
  82.         RectFill( Wnd->RPort,
  83.                   x + 2, y + 1,
  84.                   x + ScaleX( Gauge->Width ) - 3,
  85.                   y + ScaleY( Gauge->Height ) - 2 );
  86.     }
  87. }
  88.  
  89. ##DATA
  90.  
  91. struct FuelGauge %oGauge = {
  92.     %x, %y,
  93.     %W, %h,
  94.     0, 0,
  95.     %f
  96. };
  97.  
  98. ##RENDER
  99.  
  100.     DrawFuel( %wWnd, &%oGauge );
  101.     SetFuel( %wWnd, &%oGauge );
  102.  
  103. ##HEADER
  104.  
  105. struct FuelGauge {
  106.     WORD    Left, Top;
  107.     UWORD   Width, Height;
  108.     ULONG   Tot, Part;
  109.     UBYTE   Freedom;
  110. };
  111.  
  112. extern void SetFuel( struct Window *, struct FuelGauge * );
  113.  
  114. ##EXTERN
  115. extern struct FuelGauge             %oGauge;
  116.  
  117. ##end
  118.